import 'package:easy_chat_app/commons/GlobalStatus.dart';
import 'package:easy_chat_app/commons/utils/RouteUtils.dart';
import 'package:easy_chat_app/mobile/constants/MobileAppGlobalConstants.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:provider/provider.dart';

class MobileAddFriendPageChangeNotifier extends ChangeNotifier {}

class MobileAddFriendPage extends StatelessWidget {
  final Logger logger = Logger();

  MobileAddFriendPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Consumer<AppUserDetailChangeNotifier>(
        builder: (context, appUserDetailChangeNotifier, child) {
      return MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (context) {
            return MobileAddFriendPageChangeNotifier();
          })
        ],
        builder: (context, child) {
          return Scaffold(
            appBar: AppBar(
              title: const Text("添加好友"),
              centerTitle: true,
              surfaceTintColor: MobileAppGlobalConstants.appBarSurfaceTintColor,
              backgroundColor: MobileAppGlobalConstants.appBarBackgroundColor,
            ),
            body: Column(
              children: [
                createListItem(
                    icon: const ImageIcon(
                      AssetImage("images/扫一扫.png"),
                      color: Colors.blue,
                      size: 20,
                    ),
                    name: "扫一扫",
                    nameDesc: "扫描二维码名片",
                    onTap: () async {
                      await RouteUtils.route2MobileQRCodeScanPage();
                    })
              ],
            ),
          );
        },
      );
    });
  }

  Widget createListItem(
      {required ImageIcon icon,
      required String name,
      required String nameDesc,
      Future<void> Function()? onTap}) {
    return GestureDetector(
      onTap: onTap,
      child: Container(
        height: 70,
        alignment: Alignment.centerLeft,
        margin: const EdgeInsets.only(left: 20, right: 20),
        child: Row(
          children: [
            Container(
              child: icon,
            ),
            const SizedBox(
              width: 15,
            ),
            Expanded(
                child: Container(
              alignment: Alignment.centerLeft,
              decoration: const BoxDecoration(
                  border: Border(
                      bottom:
                          BorderSide(color: Color.fromRGBO(228, 228, 228, 1)))),
              height: 70,
              child: Row(
                children: [
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text(
                        name,
                        style:
                            const TextStyle(color: Colors.black, fontSize: 16),
                      ),
                      Text(
                        nameDesc,
                        style: const TextStyle(
                            color: Color.fromRGBO(171, 171, 171, 1),
                            fontSize: 12),
                      )
                    ],
                  ),
                  const Spacer(),
                  const Icon(
                    Icons.chevron_right_sharp,
                    color: Color.fromRGBO(181, 181, 181, 1),
                  )
                ],
              ),
            )),
          ],
        ),
      ),
    );
  }
}
